<?php

namespace App\Models\User;

use App\Models\Order\OrderSample;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class FamilyUser extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'family_users';

    protected $guarded = [];

    protected $appends = [
        'report_cnt',
    ];

    public function reportCnt() : Attribute
    {
        $orderSampleCnt = OrderSample::where('checker_id', $this->id)->whereIn('status', [3, 4])->count();
        return Attribute::make(
            get: fn () => $orderSampleCnt,
        );
    }
}
